<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use App\User;
Route::group(['middleware' => ['web']], function () {

    Route::get('/', function () {

        return view('welcome');
    });
    
    Route::get('/user/emailValidate','UserController@emailValidate');
    
    Route::get('/user/resetPasswordValidate','UserController@resetPasswordValidate');
    
    Route::get('/user/resendValidateEmail','UserController@resendValidateEmailWeb');
});

Route::group(['prefix'=>'api','middleware'=>'Api'],function(){ // api requests
    
    Route::get('/user/test',function(){
        $user = User::where('email','123')->first();
        $t = $user->heartbeat_at;
        Api::setDebug(true);
        return Api::isHeartbeatExpired($user)?'t':'f';
    });
    
    Route::post('/user/register','UserController@register');
    
    Route::post('/user/login','UserController@login');
    
    Route::post('/user/resetPassword','UserController@resetPassword');
    
    Route::post('/user/resendValidateEmail','UserController@resendValidateEmail');
    
    Route::group(['middleware'=>'ApiValide'],function(){    // requests with api_token valid
        
        Route::post('/user/heartbeat','UserController@heartbeat');

    });
    
});
